﻿using AutoMapper;
using XUCore.Ddd.Domain;
using XUCore.NetCore.FreeSql.Entity;

namespace XUCore.NetCore.FreeSql.Curd
{
    /// <summary>
    /// FreeSql Mark CurdService（多库FreeSql实例）<para></para>
    /// 基于Curd操作的基类<para></para>
    /// 自动生成 Create、Update、Delete、BatchDelete、SoftDelete、BatchSoftDelete、Get、GetList、GetPage 操作<para></para>
    /// 其中自动生成API：Create、Update、Delete、Get、GetList、GetPage<para></para>
    /// 由于业务不同查询的条件不同，GetList、GetPage需要重写
    /// </summary>
    /// <typeparam name="TMark"></typeparam>
    /// <typeparam name="TKey">主键类型</typeparam>
    /// <typeparam name="TEntity">数据库实体</typeparam>
    /// <typeparam name="TDto">返回实体</typeparam>
    public abstract class MarkCurdService<TMark, TKey, TEntity, TDto> : CurdService<TKey, TEntity, TDto>
        where TEntity : EntityFull<TKey>, new()
        where TDto : class, new()
    {
        /// <summary>
        /// FreeSql Mark CurdService（多库FreeSql实例）
        /// </summary>
        /// <param name="muowm"></param>
        /// <param name="mapper"></param>
        /// <param name="user"></param>
        public MarkCurdService(MarkUnitOfWorkManager<TMark> muowm, IMapper mapper, IUser user) : base(muowm.Orm, mapper, user)
        {
            muowm.Binding(repo);
        }
    }
    /// <summary>
    /// FreeSql Mark CurdService（多库FreeSql实例）<para></para>
    /// 基于Curd操作的基类<para></para>
    /// 自动生成 Create、Update、Delete、BatchDelete、SoftDelete、BatchSoftDelete、Get、GetList、GetPage 操作<para></para>
    /// 其中自动生成API：Create、Update、Delete、Get、GetList、GetPage<para></para>
    /// 由于业务不同查询的条件不同，GetList、GetPage需要重写
    /// </summary>
    /// <typeparam name="TMark"></typeparam>
    /// <typeparam name="TKey">主键类型</typeparam>
    /// <typeparam name="TEntity">数据库实体</typeparam>
    /// <typeparam name="TDto">返回实体</typeparam>
    /// <typeparam name="TCreateCommand">创建命令</typeparam>
    /// <typeparam name="TUpdateCommand">修改命令</typeparam>
    /// <typeparam name="TQueryCommand">查询列表命令</typeparam>
    /// <typeparam name="TQueryPageCommand">查询分页命令</typeparam>
    public abstract class MarkCurdService<TMark, TKey, TEntity, TDto, TCreateCommand, TUpdateCommand, TQueryCommand, TQueryPageCommand> :
        CurdService<TKey, TEntity, TDto, TCreateCommand, TUpdateCommand, TQueryCommand, TQueryPageCommand>
            where TEntity : EntityFull<TKey>, new()
            where TDto : class, new()
            where TCreateCommand : CreateCommand
            where TUpdateCommand : UpdateCommand<TKey>
            where TQueryCommand : ListCommand
            where TQueryPageCommand : PageCommand
    {
        /// <summary>
        /// FreeSql Mark CurdService（多库FreeSql实例）
        /// </summary>
        /// <param name="muowm"></param>
        /// <param name="mapper"></param>
        /// <param name="user"></param>
        public MarkCurdService(MarkUnitOfWorkManager<TMark> muowm, IMapper mapper, IUser user) : base(muowm.Orm, mapper, user)
        {
            muowm.Binding(repo);
        }

        //public MarkCurdService(MarkUnitOfWorkManager<TMark> muowm, IMapper mapper, IUser user, Expression<Func<TEntity, bool>> filter, Func<string, string> asTable = null) :
        //    base(muowm.Orm, mapper, filter, asTable)
        //{
        //    muowm.Binding(this);

        //    User = user;
        //}
    }
}
